package com.git_taoxian.test5;

import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Test {
    public static void main(String[] args) {
//        创建一个properties对象
        Properties properties = new Properties();
        Object rs = null;
        try {
            properties.load(new FileReader("homework/config.properties"));
//        获取DemoClass类的对象
            Class clz = Class.forName(properties.getProperty("className"));
//        获取run()方法的对象
            Method method = clz.getDeclaredMethod("run");
//        获取当前类的对象
            DemoClass dc = (DemoClass) clz.getDeclaredConstructor().newInstance();
//        执行run方法
            rs = method.invoke(dc);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
